﻿Public Class frmQuanLiLopHoc

    Private Sub frmQuanLiLopHoc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lopBUS As New LopBUS()
        Dim ds As List(Of LopDTO)
        ds = lopBUS.LayDSLopHoc()

        dgvDSLop.Rows.Clear()
        For Each lop As LopDTO In ds
            dgvDSLop.Rows.Add(lop.MALOP, lop.TENLOP, lop.SISO, lop.KHOI, lop.NAM, lop.MAKHOI)
        Next
    End Sub


    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        Try
            If (dgvDSLop.SelectedRows.Count > 0) Then
                Dim lopBUS As New LopBUS()
                Dim row As DataGridViewRow = dgvDSLop.SelectedRows(0)
                Dim maKHOI As Integer = Integer.Parse(row.Cells(0).Value)

                Dim frm As New frmSuaChiTietLopHoc()
                'frm.MaHS = maHS
                frm.txtTenLop.Text = row.Cells(1).Value.ToString()
                frm.txtSiSo.Text = row.Cells(2).Value.ToString()
                frm.txtTenKhoi.Text = row.Cells(3).Value.ToString()
                frm.txtNam.Text = row.Cells(4).Value.ToString()
                frm.MaLop = maKHOI
                frm.ShowDialog()

                Dim ds As List(Of LopDTO)
                ds = lopBUS.LayDSLopHoc()

                dgvDSLop.Rows.Clear()
                For Each lop As LopDTO In ds
                    dgvDSLop.Rows.Add(lop.MALOP, lop.TENLOP, lop.SISO, lop.KHOI, lop.NAM, lop.MAKHOI)
                Next
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class